<template>
  <div class="tit_wrap">
    <div class="tit_item active">全部</div>
    <div
      class="tit_item"
      :class="{ active: navCurrent == index }"
      v-for="(item, index) in options"
      :key="index"
      @click="toggle(index, item)"
      >{{ item.name }}</div
    >
  </div>
</template>

<script setup>
  import { ref, onMounted } from 'vue';
  import { get_list2 } from '@/api/user/store_teams';
  import { get_store_select } from '@/api/material/select';
	

  const emit = defineEmits(['initStore', 'selStore']);

  const options = ref([]);
  const navCurrent = ref(0);

  onMounted(() => {
    get_store_select({ page: 1, page_size: 99999 }).then((res) => {
      options.value = [];
	  res.forEach(item=>{
		  options.value.push({
			  name:item.label,
			  code:item.value
		  })
	  })
      if (options.value.length > 0) {
        emit('initStore', options.value[0]);
      }
    });
  });
  const toggle = (index, item) => {
    navCurrent.value = index;
    //触发父级更新数据
    emit('selStore', item);
  };
</script>
